package mf.trees.all;
import java.io.IOException;
import javax.swing.JFileChooser;

/**
 * For monadic straight-line tree grammars with terminal symbols of any rank.
 * 
 * @author Maik Funkat
 */
public class treeNavigate {

	//help text displayed when you dont specify a file to rePair
		private final static String helpText = 
			"Usage: treeNavigateAll [debug]\n"+
		    "Add debug as parameter to show additional debugging information.\n";

	//debug mode displays more informations
	private static boolean DEBUG_MODE = false;
	
	/** Starts the program. */
	public static void main(String[] args) throws IOException {
		System.out.println("TreeNavigate - arbitrary ranked alphabet\n"+helpText);
		
		//parameter evaluation
		switch (args.length) {
		case 0:
			System.out.println(helpText);
			break;
		default:
			if (args[0].equals("debug"))
				DEBUG_MODE = true;
			break;
		}
		
		JFileChooser jfc = new JFileChooser(".\\tests\\trees");
		jfc.setDialogTitle("Select a tree grammar (.g files)...");
		
		if(jfc.showOpenDialog(null) != JFileChooser.APPROVE_OPTION)
			System.exit(0);
		
		//create model
		TreeModel tm = new TreeModel(jfc.getSelectedFile(), DEBUG_MODE);
		
		//create GUI
		TreeFrame window = new TreeFrame("TreeNavigate: "+jfc.getSelectedFile().getAbsolutePath(), tm);
		
		//listen for navigational commands
		window.setVisible(true);
	}
}